Skip to content

fix: reject non-http public base URLs - #230

Open
teddyli18000 wants to merge 1 commit into
Waishnav:mainfrom
teddyli18000:fix/public-base-url-protocol
Open

fix: reject non-http public base URLs#230
teddyli18000 wants to merge 1 commit into
Waishnav:mainfrom
teddyli18000:fix/public-base-url-protocol

Conversation

@teddyli18000

@teddyli18000 teddyli18000 commented Aug 23, 2026

Copy link
Copy Markdown

Summary

  • enforce the existing HTTP(S) requirement when loading publicBaseUrl from persisted config or DEVSPACE_PUBLIC_BASE_URL
  • apply the same normalization/validation before persisted config writes, so devspace config set publicBaseUrl ... cannot save an unsupported scheme
  • keep the previous config file unchanged when validation fails

Why

Interactive setup already rejects non-HTTP(S) public URLs, but the persisted-config and environment-variable load paths accepted any scheme supported by URL. For example, ftp://example.com/devspace could be saved and later surfaced by devspace doctor as an FTP MCP URL.

This makes the HTTP(S) requirement a shared invariant across setup/config writes and runtime config loading.

Tests

Regression coverage verifies that:

  • an FTP URL supplied through DEVSPACE_PUBLIC_BASE_URL is rejected
  • an FTP URL in config.json is rejected
  • a failed persisted-config write does not overwrite the previous valid config

Prior work

#37 previously included setter-side HTTP(S) validation as part of a much larger config-management change, but that PR was closed without merging and did not enforce the invariant in the runtime load path. This PR isolates that validation and applies it consistently to all current config sources.

Summary by CodeRabbit

  • Bug Fixes
    • Improved public URL validation to accept only HTTP and HTTPS addresses.
    • Automatically removes unsupported URL fragments and query parameters and standardizes trailing slashes.
    • Preserves support for wildcard hosts.
    • Prevented invalid configuration updates from overwriting existing settings.

Copilot AI lite review requested due to automatic review settings August 23, 2026 16:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f1fc695-7abd-4aa8-9863-f6dfe33a9d5d

📥 Commits

Reviewing files that changed from the base of the PR and between fdbff75 and d7f742a.

📒 Files selected for processing (3)
  • src/config.test.ts
  • src/config.ts
  • src/user-config.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The change centralizes public URL normalization, restricts URLs to HTTP(S), applies normalization during configuration loading and writing, and adds tests for invalid URLs, persisted configuration, wildcard hosts, and write safety.

Changes

Public URL normalization

Layer / File(s) Summary
Normalization and persistence
src/user-config.ts
Adds normalizePublicBaseUrl to validate HTTP(S) URLs, remove queries and fragments, and trim trailing slashes. writeDevspaceConfig writes a normalized copy when publicBaseUrl is set.
Load integration and validation tests
src/config.ts, src/config.test.ts
loadConfig uses the shared normalizer. Tests reject ftp URLs, preserve wildcard host behavior, validate persisted configuration, and confirm failed writes do not change existing files.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to d7f74

The change consistently rejects unsupported public URL schemes and preserves the existing configuration when validation fails; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: waishnav

Poem

A rabbit checks each URL in line,
Keeps HTTP paths neat and fine.
FTP hops are turned away,
Safe files stay unchanged today.
Query and fragment fade from view.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: rejecting non-HTTP public base URLs.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 23, 2026

Copy link
Copy Markdown

Greptile Summary

This PR centralizes publicBaseUrl normalization and enforces HTTP(S) validation for environment values, persisted configuration, and configuration writes.

  • Moves runtime URL normalization into a shared user-config helper.
  • Validates before writing so rejected updates leave the existing configuration unchanged.
  • Adds regression coverage for invalid environment, persisted-file, and write-path values.

Confidence Score: 5/5

The PR appears safe to merge, with invalid public URL schemes consistently rejected before runtime use or persistence.

The shared normalizer preserves existing HTTP(S) normalization behavior, rejects only unsupported schemes, and validates before filesystem mutation so failed writes retain the previous configuration.

Important Files Changed

Filename Overview
src/config.ts Replaces the local URL parser with the shared HTTP(S)-enforcing normalizer while preserving effective-config precedence and host derivation.
src/user-config.ts Adds shared public URL validation and normalizes non-null values before any persisted configuration write.
src/config.test.ts Covers rejected FTP values from environment and persisted config, plus preservation of the prior file after a rejected write.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  E["Environment publicBaseUrl"] --> N["Normalize and require HTTP(S)"]
  P["Persisted publicBaseUrl"] --> N
  W["Configuration write"] --> N
  N -->|Valid| C["Effective or persisted configuration"]
  N -->|Invalid| R["Reject without overwriting config"]
Loading

Reviews (1): Last reviewed commit: "fix: reject non-http public base URLs" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants